﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QLDAOL.Models;
using QLDAOL.Util;
using QLDAOL.ModelView;

namespace QLDAOL.Controllers
{
    public class UserController : BaseController
    {
        //
        // GET: /Index/
        public IEQLDAOLRepository repository = new IEQLDAOLRepository();
        public ActionResult UserPage(int ID_PJ=0)
        {
            return View();
        }
        public ActionResult AccessDenied()
        {
            return View();
        }
        public ActionResult ListUser()
        {
            int id = int.Parse(Session["pjID"].ToString());
            var lstUser = repository.getlstUserRoleByPJID(id);
            ViewData["lstUser"] = lstUser;
            return PartialView();
        }
        public ActionResult AddUser()
        {
            var lstRole = repository.getlstPJRole();
            ViewData["lstRole"] = lstRole;
            return PartialView();
        }
        public ActionResult AddUserAct()
        {
            string email = Request.Form["email"].ToString();
            int role = int.Parse(Request.Form["role"].ToString());
            int id = int.Parse(Session["pjID"].ToString());
            repository.addUserProject(email, role, id);
            return RedirectToAction("ListUser");
        }
    }
}
